package com.example.demo.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.convert.PointsConvert;
import com.example.demo.domain.base.PageParam;
import com.example.demo.domain.base.PageResult;
import com.example.demo.domain.entity.GiftGivingDO;
import com.example.demo.domain.param.GiftGivingCreateParam;
import com.example.demo.domain.param.GiftGivingUpdateParam;
import com.example.demo.domain.vo.GiftGivingVO;
import com.example.demo.dao.GiftGivingMapper;
import com.example.demo.service.GiftGivingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * GiftGivingServiceImpl
 *
 * @author haochen78
 * @date 2025/10/3 21:42
 **/
@Service
public class GiftGivingServiceImpl implements GiftGivingService {

    @Autowired
    private GiftGivingMapper giftGivingMapper;


    @Override
    public PageResult<GiftGivingVO> listGiftGivings(PageParam param) {
        Page<GiftGivingDO> page = giftGivingMapper.selectPage(new Page<>(param.getPageNum(), param.getPageSize()), null);
        Page<GiftGivingVO> pageInfo = PointsConvert.INSTANCE.giftGivingDoToVoPage(page);
        return new PageResult<>(pageInfo);
    }

    @Override
    public void createGiftGiving(GiftGivingCreateParam param) {
        GiftGivingDO giftGivingDO = PointsConvert.INSTANCE.giftGivingParamToDo(param);
        giftGivingMapper.insert(giftGivingDO);
    }

    @Override
    public void updateGiftGiving(GiftGivingUpdateParam param) {
        GiftGivingDO giftGivingDO = PointsConvert.INSTANCE.giftGivingParamToDo(param);
        giftGivingMapper.updateById(giftGivingDO);
    }

    @Override
    public void deleteGiftGiving(Long id) {
        giftGivingMapper.deleteById(id);
    }
}
